import pandas as pd 
import os
import time
from WindPy import w

dst_path = ".\\"

def get_wind():
    if not w.isconnected():
        w.start()
    return w

if __name__ == "__main__":
#    codelist = ['511880.SH', '204001.SH', '511990.SH']
    codelist = ['511880.OF', '511990.OF']
    codelist = ['204001.SH']
    for code in codelist:
        d = get_wind().wsd(code, 'close, volume, amt', '2015-01-01', '2016-07-29', 'Fill=Previous')
        df = pd.DataFrame()
        df["#Ticker"] = [code]*len(d.Times)
        df["Data"] = d.Times
        df["Close"] = d.Data[0]
        df["Volume"] = d.Data[1]
        df["Amount"] = d.Data[2]
        df.to_csv(dst_path+code+".csv", index=False)
        time.sleep(3)
		